home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bchelp10.zip / TI641.ASC < prev    next >
Text File  |  1991-09-11  |  2KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C++                            NUMBER  :  641
  9.   VERSION  :  2.0
  10.        OS  :  PC DOS
  11.      DATE  :  September 11, 1991                       PAGE  :  1/2
  12.  
  13.     TITLE  :  Using Interrupt Functions in C++ Programs
  14.  
  15.  
  16.  
  17.  
  18.   /************************************************************************
  19.      example of installing an interrupt function in a C++ program
  20.   ************************************************************************/
  21.   #pragma option -w -w-par
  22.   #include <conio.h>
  23.   #include <dos.h>
  24.  
  25.   typedef void interrupt (*cast_isr) (...);
  26.  
  27.   void install(void interrupt (*faddr)(...), int inum);
  28.   void interrupt mybeep(unsigned, unsigned, unsigned, unsigned,
  29.                         unsigned, unsigned, unsigned, unsigned,
  30.                         unsigned);
  31.   void testbeep(unsigned char bcount, int inum);
  32.  
  33.   //-----------------
  34.   int main(void)
  35.   {
  36.      install( (cast_isr)mybeep, 10);
  37.      testbeep(3,10);
  38.      cputs("beep");
  39.      return 0;
  40.   }
  41.  
  42.   //-----------------
  43.   void install(void interrupt (*faddr)(...), int inum)
  44.   {
  45.       setvect(inum, faddr);
  46.   }
  47.  
  48.   //-----------------
  49.   void interrupt mybeep(unsigned bp, unsigned di, unsigned si,
  50.                         unsigned ds, unsigned es, unsigned dx,
  51.                         unsigned cx, unsigned bx, unsigned ax)
  52.   {
  53.      int i, j;
  54.      char originalbits, bits;
  55.      int bcount = 2000;
  56.  
  57.      bits = originalbits = inportb(0x61);
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C++                            NUMBER  :  641
  75.   VERSION  :  2.0
  76.        OS  :  PC DOS
  77.      DATE  :  September 11, 1991                       PAGE  :  2/2
  78.  
  79.     TITLE  :  Using Interrupt Functions in C++ Programs
  80.  
  81.  
  82.  
  83.  
  84.      for (i = 0; i <= bcount; i++)
  85.      {  outportb(0x61, bits & 0xfc);
  86.         for (j = 0; j <= 300; j++);
  87.         outportb(0x61, bits | 2);
  88.         for (j=0; j<=300; j++);
  89.      }
  90.      outportb(0x61, originalbits);
  91.   }
  92.  
  93.   //-----------------
  94.   void testbeep(unsigned char bcount, int inum)
  95.   {
  96.      _AH = bcount;
  97.      geninterrupt(inum);
  98.   }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.